import 'package:guochaoapp/model/cart_settle_entity.dart';

cartSettleEntityFromJson(CartSettleEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new CartSettleData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> cartSettleEntityToJson(CartSettleEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

cartSettleDataFromJson(CartSettleData data, Map<String, dynamic> json) {
	if (json['priceTotal'] != null) {
		data.priceTotal = json['priceTotal'] is String
				? double.tryParse(json['priceTotal'])
				: json['priceTotal'].toDouble();
	}
	if (json['weightTotal'] != null) {
		data.weightTotal = json['weightTotal'] is String
				? double.tryParse(json['weightTotal'])
				: json['weightTotal'].toDouble();
	}
	if (json['pipeWeightTotal'] != null) {
		data.pipeWeightTotal = json['pipeWeightTotal'] is String
				? double.tryParse(json['pipeWeightTotal'])
				: json['pipeWeightTotal'].toDouble();
	}
	if (json['otherWeightTotal'] != null) {
		data.otherWeightTotal = json['otherWeightTotal'] is String
				? double.tryParse(json['otherWeightTotal'])
				: json['otherWeightTotal'].toDouble();
	}
	if (json['userBalanceFrozen'] != null) {
		data.userBalanceFrozen = json['userBalanceFrozen'];
	}
	if (json['userBalance'] != null) {
		data.userBalance = json['userBalance'] is String
				? double.tryParse(json['userBalance'])
				: json['userBalance'].toDouble();
	}
	if (json['itemList'] != null) {
		data.itemList = new List<CartSettleDataItemList>();
		(json['itemList'] as List).forEach((v) {
			data.itemList.add(new CartSettleDataItemList().fromJson(v));
		});
	}
	if (json['keyList'] != null) {
		data.keyList = json['keyList']?.map((v) => v.toString())?.toList()?.cast<String>();
	}
	if (json['cartSkuList'] != null) {
		data.cartSkuList = new List<CartSettleDataCartSkuList>();
		(json['cartSkuList'] as List).forEach((v) {
			data.cartSkuList.add(new CartSettleDataCartSkuList().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> cartSettleDataToJson(CartSettleData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['priceTotal'] = entity.priceTotal;
	data['weightTotal'] = entity.weightTotal;
	data['pipeWeightTotal'] = entity.pipeWeightTotal;
	data['otherWeightTotal'] = entity.otherWeightTotal;
	data['userBalanceFrozen'] = entity.userBalanceFrozen;
	data['userBalance'] = entity.userBalance;
	if (entity.itemList != null) {
		data['itemList'] =  entity.itemList.map((v) => v.toJson()).toList();
	}
	data['keyList'] = entity.keyList;
	if (entity.cartSkuList != null) {
		data['cartSkuList'] =  entity.cartSkuList.map((v) => v.toJson()).toList();
	}
	return data;
}

cartSettleDataItemListFromJson(CartSettleDataItemList data, Map<String, dynamic> json) {
	if (json['categoryImg'] != null) {
		data.categoryImg = json['categoryImg'].toString();
	}
	if (json['categoryName'] != null) {
		data.categoryName = json['categoryName'].toString();
	}
	if (json['itemNum'] != null) {
		data.itemNum = json['itemNum'] is String
				? int.tryParse(json['itemNum'])
				: json['itemNum'].toInt();
	}
	if (json['itemPrice'] != null) {
		data.itemPrice = json['itemPrice'] is String
				? double.tryParse(json['itemPrice'])
				: json['itemPrice'].toDouble();
	}
	if (json['expand'] != null) {
		data.expand = json['expand'];
	}
	if (json['itemList'] != null) {
		data.itemList = new List<CartSettleDataItemListItemList>();
		(json['itemList'] as List).forEach((v) {
			data.itemList.add(new CartSettleDataItemListItemList().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> cartSettleDataItemListToJson(CartSettleDataItemList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['categoryImg'] = entity.categoryImg;
	data['categoryName'] = entity.categoryName;
	data['itemNum'] = entity.itemNum;
	data['itemPrice'] = entity.itemPrice;
	data['expand'] = entity.expand;
	if (entity.itemList != null) {
		data['itemList'] =  entity.itemList.map((v) => v.toJson()).toList();
	}
	return data;
}

cartSettleDataItemListItemListFromJson(CartSettleDataItemListItemList data, Map<String, dynamic> json) {
	if (json['skuId'] != null) {
		data.skuId = json['skuId'] is String
				? int.tryParse(json['skuId'])
				: json['skuId'].toInt();
	}
	if (json['spuId'] != null) {
		data.spuId = json['spuId'];
	}
	if (json['mallTitle'] != null) {
		data.mallTitle = json['mallTitle'].toString();
	}
	if (json['brandId'] != null) {
		data.brandId = json['brandId'] is String
				? int.tryParse(json['brandId'])
				: json['brandId'].toInt();
	}
	if (json['brandName'] != null) {
		data.brandName = json['brandName'].toString();
	}
	if (json['skuSpec'] != null) {
		data.skuSpec = json['skuSpec'].toString();
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? double.tryParse(json['price'])
				: json['price'].toDouble();
	}
	if (json['num'] != null) {
		data.num = json['num'] is String
				? int.tryParse(json['num'])
				: json['num'].toInt();
	}
	if (json['stock'] != null) {
		data.stock = json['stock'] is String
				? int.tryParse(json['stock'])
				: json['stock'].toInt();
	}
	if (json['weight'] != null) {
		data.weight = json['weight'] is String
				? double.tryParse(json['weight'])
				: json['weight'].toDouble();
	}
	if (json['categoryName'] != null) {
		data.categoryName = json['categoryName'].toString();
	}
	if (json['unit'] != null) {
		data.unit = json['unit'].toString();
	}
	if (json['isPipe'] != null) {
		data.isPipe = json['isPipe'];
	}
	if (json['mallFee'] != null) {
		data.mallFee = json['mallFee'] is String
				? double.tryParse(json['mallFee'])
				: json['mallFee'].toDouble();
	}
	if (json['repoFee'] != null) {
		data.repoFee = json['repoFee'] is String
				? double.tryParse(json['repoFee'])
				: json['repoFee'].toDouble();
	}
	if (json['returnFee'] != null) {
		data.returnFee = json['returnFee'] is String
				? double.tryParse(json['returnFee'])
				: json['returnFee'].toDouble();
	}
	if (json['checked'] != null) {
		data.checked = json['checked'];
	}
	return data;
}

Map<String, dynamic> cartSettleDataItemListItemListToJson(CartSettleDataItemListItemList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['skuId'] = entity.skuId;
	data['spuId'] = entity.spuId;
	data['mallTitle'] = entity.mallTitle;
	data['brandId'] = entity.brandId;
	data['brandName'] = entity.brandName;
	data['skuSpec'] = entity.skuSpec;
	data['price'] = entity.price;
	data['num'] = entity.num;
	data['stock'] = entity.stock;
	data['weight'] = entity.weight;
	data['categoryName'] = entity.categoryName;
	data['unit'] = entity.unit;
	data['isPipe'] = entity.isPipe;
	data['mallFee'] = entity.mallFee;
	data['repoFee'] = entity.repoFee;
	data['returnFee'] = entity.returnFee;
	data['checked'] = entity.checked;
	return data;
}

cartSettleDataCartSkuListFromJson(CartSettleDataCartSkuList data, Map<String, dynamic> json) {
	if (json['skuId'] != null) {
		data.skuId = json['skuId'] is String
				? int.tryParse(json['skuId'])
				: json['skuId'].toInt();
	}
	if (json['spuId'] != null) {
		data.spuId = json['spuId'];
	}
	if (json['mallTitle'] != null) {
		data.mallTitle = json['mallTitle'].toString();
	}
	if (json['brandId'] != null) {
		data.brandId = json['brandId'] is String
				? int.tryParse(json['brandId'])
				: json['brandId'].toInt();
	}
	if (json['brandName'] != null) {
		data.brandName = json['brandName'].toString();
	}
	if (json['skuSpec'] != null) {
		data.skuSpec = json['skuSpec'].toString();
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? int.tryParse(json['price'])
				: json['price'].toInt();
	}
	if (json['num'] != null) {
		data.num = json['num'] is String
				? int.tryParse(json['num'])
				: json['num'].toInt();
	}
	if (json['stock'] != null) {
		data.stock = json['stock'] is String
				? int.tryParse(json['stock'])
				: json['stock'].toInt();
	}
	if (json['weight'] != null) {
		data.weight = json['weight'] is String
				? double.tryParse(json['weight'])
				: json['weight'].toDouble();
	}
	if (json['categoryName'] != null) {
		data.categoryName = json['categoryName'].toString();
	}
	if (json['unit'] != null) {
		data.unit = json['unit'].toString();
	}
	if (json['isPipe'] != null) {
		data.isPipe = json['isPipe'];
	}
	if (json['mallFee'] != null) {
		data.mallFee = json['mallFee'] is String
				? double.tryParse(json['mallFee'])
				: json['mallFee'].toDouble();
	}
	if (json['repoFee'] != null) {
		data.repoFee = json['repoFee'] is String
				? double.tryParse(json['repoFee'])
				: json['repoFee'].toDouble();
	}
	if (json['returnFee'] != null) {
		data.returnFee = json['returnFee'] is String
				? double.tryParse(json['returnFee'])
				: json['returnFee'].toDouble();
	}
	if (json['checked'] != null) {
		data.checked = json['checked'];
	}
	return data;
}

Map<String, dynamic> cartSettleDataCartSkuListToJson(CartSettleDataCartSkuList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['skuId'] = entity.skuId;
	data['spuId'] = entity.spuId;
	data['mallTitle'] = entity.mallTitle;
	data['brandId'] = entity.brandId;
	data['brandName'] = entity.brandName;
	data['skuSpec'] = entity.skuSpec;
	data['price'] = entity.price;
	data['num'] = entity.num;
	data['stock'] = entity.stock;
	data['weight'] = entity.weight;
	data['categoryName'] = entity.categoryName;
	data['unit'] = entity.unit;
	data['isPipe'] = entity.isPipe;
	data['mallFee'] = entity.mallFee;
	data['repoFee'] = entity.repoFee;
	data['returnFee'] = entity.returnFee;
	data['checked'] = entity.checked;
	return data;
}